package com.letwal.cmcvnd.me

import android.annotation.SuppressLint
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.lifecycle.ViewModel
import com.letwal.cmcvnd.base.BaseActivity
import com.letwal.cmcvnd.base.BaseFragment
import com.letwal.cmcvnd.databinding.FragmentMeBinding
import com.letwal.cmcvnd.extend.*
import com.letwal.cmcvnd.home.HomeActivity


class MeHomeFragment : BaseFragment() {

    private lateinit var mFragmentBinding: FragmentMeBinding

    override fun onBindingViewModel(): List<ViewModel> {
        val list = mutableListOf<ViewModel>()
        return list
    }

    override fun onCreateView(
        inflater: LayoutInflater, container: ViewGroup?,
        savedInstanceState: Bundle?,
    ): View {
        mFragmentBinding =
            FragmentMeBinding.inflate(inflater, container, false)
        return mFragmentBinding.root
    }

    @SuppressLint("NotifyDataSetChanged", "SetTextI18n")
    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)

        try {
            //点击 manager my wallet
            mFragmentBinding.rlMyManagerMyWallet.setOnClickListener {
                (requireActivity() as BaseActivity).startToMyWalletActivity()
            }

            //点击 my earn
            mFragmentBinding.rlMyMyEarn.setOnClickListener {
                (requireActivity() as HomeActivity).toEarnTab()
            }

            //点击 invite
            mFragmentBinding.rlMyInvite.setOnClickListener {
                (requireActivity() as BaseActivity).startToInviteActivity()
            }

            //点击 setting
            mFragmentBinding.rlMySetting.setOnClickListener {
                (requireActivity() as BaseActivity).startToSettingActivity()
            }

            //点击 term of use
            mFragmentBinding.rlMyTermsOfUse.setOnClickListener {
                (requireActivity() as BaseActivity).startToTermOfUseActivity()
            }

            //点击 about us
            mFragmentBinding.rlMyAboutUs.setOnClickListener {
                (requireActivity() as BaseActivity).startToAboutUsWebViewActivity()
            }

            //点击 contact us
            mFragmentBinding.rlMyCustomerService.setOnClickListener {
                (requireActivity() as BaseActivity).startToCustomerServiceActivity()
            }

            //点击 退出
            mFragmentBinding.submitMyLogout.setOnClickListener {
                (requireActivity() as BaseActivity).startToLoginActivity()
            }

        } catch (e: Exception) {
            e.printStackTrace()
        }
    }
}